//导入自己封装的axios模块
import ZZYRequest from './request/index'

import LocalCache from '@/utils/cache'
// 创建axios实例  前面我已经定义了类型  要求传入interceptors hooks 回调函数
const zzyRequest = new ZZYRequest({
  baseURL:'http://localhost:8081',
  timeout: 50000,
  interceptors: {
    requestInterceptor: (config) => {
      // 拦截器里添加token
      const token = LocalCache.getCache('token')
      if (token) {
        config.headers.Authorization = ` Bearer ${token}`
      }
      return config
    },
    requestInterceptorCatch: (error) => {
      return error
    },
    responseInterceptor: (res) => {
      return res
    },
    responseInterceptorCatch: (error) => {
      return error
    }
  }
})
export default zzyRequest
